<template>
	<el-dialog :title="dialogTitle" :visible.sync="visible" top="0" width="560px" append-to-body>
		<el-form v-bind="formConfig" :model="formData" :rules="formRules" label-width="80px" v-loading="loading">
			<el-row :gutter="16">
				<el-col :span="24">
					<el-form-item label="分类名称" prop="name">
						<el-input v-model="formData.name" placeholder="请输入分类名称" maxlength="30" show-word-limit></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="14">
					<el-form-item label="分类类型" prop="classType">
						<el-select v-model="formData.classType" placeholder="请选择分类类型" disabled style="width: 100%">
							<el-option v-for="(item, index) in dictData['SYS_CLASSIFY']" :key="index" :label="`${item.deName}分类`" :value="item.deValue" />
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="10">
					<el-form-item label="排序" prop="orderBy" label-width="50px">
						<el-input-number v-model="formData.orderBy" controls-position="right" :min="1" style="width: 100%" />
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="分类描述" prop="des">
						<el-input type="textarea" v-model="formData.des" placeholder="请输入分类描述"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
		</el-form>
		<template slot="footer">
			<el-button size="medium" @click="visible = false">取消</el-button>
			<el-button size="medium" type="primary" :loading="btnLoading" @click="handleSubmitForm()">{{ formTypeName }}</el-button>
		</template>
	</el-dialog>
</template>

<script>
import moment from 'moment';
import { mapGetters } from 'vuex';
import formMixins from '@/mixins/formMixins';
import { queryClassify, addClassify, updateClassify } from '@/api/basedata/sysClassify';
export default {
	mixins: [formMixins],
	props: {
		type: { type: String, default: '' }
	},
	data() {
		return {
			formName: '分类',
			formRules: {
				name: [{ required: true, message: '请输入分类名称', trigger: 'blur' }],
				classType: [{ required: true, message: '请输入分类类型', trigger: 'change' }]
			}
		};
	},
	computed: {
		...mapGetters(['userInfo']),
		detailData() {
			return eval(queryClassify);
		},
		callFunction() {
			return eval(this.addOrEdit ? addClassify : updateClassify);
		},
		submitParams() {
			let data = { ...this.formData };
			data['pid'] = '0';
			// data['']
			return data;
			console.log(this.formData);
		}
	},
	methods: {
		formatFormParams() {
			this.$set(this.formData, 'classType', this.type);
		}
	}
};
</script>
